package biz.obake.team.touchprotector.f;

import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.SeekBar;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.f.l;
import biz.obake.team.touchprotector.tpservice.TPService;
import d.e;

public final class c implements l {

    /* renamed from: b  reason: collision with root package name */
    private final View f1601b;

    /* renamed from: c  reason: collision with root package name */
    private a f1602c = a.Middle;

    /* renamed from: d  reason: collision with root package name */
    private final k f1603d;

    private enum a {
        Top,
        Middle,
        Bottom
    }

    static final class b implements View.OnClickListener {

        /* renamed from: b  reason: collision with root package name */
        public static final b f1607b = new b();

        b() {
        }

        public final void onClick(View view) {
            TPService.k("Unlock", "PreviewCloseButton");
        }
    }

    /* renamed from: biz.obake.team.touchprotector.f.c$c  reason: collision with other inner class name */
    public static final class C0072c implements SeekBar.OnSeekBarChangeListener {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ c f1608a;

        C0072c(c cVar) {
            this.f1608a = cVar;
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            d.h.b.c.c(seekBar, "seekBar");
            this.f1608a.i(seekBar, i);
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
            d.h.b.c.c(seekBar, "seekBar");
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            d.h.b.c.c(seekBar, "seekBar");
        }
    }

    public static final class d implements SeekBar.OnSeekBarChangeListener {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ c f1609a;

        d(c cVar) {
            this.f1609a = cVar;
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            d.h.b.c.c(seekBar, "seekBar");
            this.f1609a.h(seekBar, i);
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
            d.h.b.c.c(seekBar, "seekBar");
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            d.h.b.c.c(seekBar, "seekBar");
        }
    }

    public c(k kVar) {
        d.h.b.c.c(kVar, "mPV");
        this.f1603d = kVar;
        View findViewById = kVar.findViewById(R.id.controlPanel);
        d.h.b.c.b(findViewById, "mPV.findViewById(R.id.controlPanel)");
        this.f1601b = findViewById;
        g();
    }

    private final void g() {
        View findViewById = this.f1601b.findViewById(R.id.closeButton);
        if (findViewById != null) {
            ((ImageButton) findViewById).setOnClickListener(b.f1607b);
            View findViewById2 = this.f1601b.findViewById(R.id.opacityBar);
            if (findViewById2 != null) {
                ((SeekBar) findViewById2).setOnSeekBarChangeListener(new C0072c(this));
                View findViewById3 = this.f1601b.findViewById(R.id.backlightBar);
                if (findViewById3 != null) {
                    ((SeekBar) findViewById3).setOnSeekBarChangeListener(new d(this));
                    return;
                }
                throw new e("null cannot be cast to non-null type android.widget.SeekBar");
            }
            throw new e("null cannot be cast to non-null type android.widget.SeekBar");
        }
        throw new e("null cannot be cast to non-null type android.widget.ImageButton");
    }

    /* access modifiers changed from: private */
    public final void h(SeekBar seekBar, int i) {
        if (i > 100) {
            i = i < seekBar.getMax() ? 100 : -1;
        }
        biz.obake.team.touchprotector.g.a.q("backlight", i);
    }

    /* access modifiers changed from: private */
    public final void i(SeekBar seekBar, int i) {
        biz.obake.team.touchprotector.g.a.q("lock_frame_opacity", (i * 100) / seekBar.getMax());
    }

    public void a() {
        l.a.c(this);
    }

    public boolean b(MotionEvent motionEvent) {
        d.h.b.c.c(motionEvent, "event");
        if (!this.f1603d.g()) {
            return false;
        }
        int top = this.f1603d.getTop();
        int bottom = this.f1603d.getBottom();
        int y = (int) motionEvent.getY();
        if (y < top) {
            y = top;
        }
        if (y > bottom) {
            y = bottom;
        }
        int i = (bottom - top) / 3;
        int i2 = top + i;
        int i3 = bottom - i;
        a aVar = a.Middle;
        if (y < i2) {
            aVar = a.Top;
        } else if (y > i3) {
            aVar = a.Bottom;
        }
        if (this.f1602c == aVar) {
            return false;
        }
        this.f1602c = aVar;
        c();
        return true;
    }

    /* JADX WARNING: Removed duplicated region for block: B:49:0x0183  */
    /* JADX WARNING: Removed duplicated region for block: B:58:0x01b4  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void c() {
        /*
            r17 = this;
            r0 = r17
            android.view.View r1 = r0.f1601b
            r2 = 2131296618(0x7f09016a, float:1.8211158E38)
            android.view.View r1 = r1.findViewById(r2)
            java.lang.String r2 = "null cannot be cast to non-null type android.widget.TextView"
            if (r1 == 0) goto L_0x01ce
            android.widget.TextView r1 = (android.widget.TextView) r1
            android.view.View r3 = r0.f1601b
            r4 = 2131296328(0x7f090048, float:1.821057E38)
            android.view.View r3 = r3.findViewById(r4)
            if (r3 == 0) goto L_0x01c8
            android.widget.TextView r3 = (android.widget.TextView) r3
            android.view.View r2 = r0.f1601b
            r4 = 2131296502(0x7f0900f6, float:1.8210922E38)
            android.view.View r2 = r2.findViewById(r4)
            java.lang.String r4 = "null cannot be cast to non-null type android.widget.SeekBar"
            if (r2 == 0) goto L_0x01c2
            android.widget.SeekBar r2 = (android.widget.SeekBar) r2
            android.view.View r5 = r0.f1601b
            r6 = 2131296326(0x7f090046, float:1.8210566E38)
            android.view.View r5 = r5.findViewById(r6)
            if (r5 == 0) goto L_0x01bc
            android.widget.SeekBar r5 = (android.widget.SeekBar) r5
            biz.obake.team.touchprotector.f.k r4 = r0.f1603d
            java.lang.String r4 = r4.getPreviewMode()
            r6 = 8
            r7 = 0
            if (r4 != 0) goto L_0x0047
            goto L_0x0176
        L_0x0047:
            int r8 = r4.hashCode()
            r9 = -1335246402(0xffffffffb069c1be, float:-8.504023E-10)
            r10 = 0
            if (r8 == r9) goto L_0x00d6
            r9 = 1346840719(0x5047288f, float:1.33652961E10)
            if (r8 == r9) goto L_0x0058
            goto L_0x0176
        L_0x0058:
            java.lang.String r8 = "backlight"
            boolean r4 = r4.equals(r8)
            if (r4 == 0) goto L_0x0176
            android.view.View r4 = r0.f1601b
            r4.setVisibility(r7)
            r1.setVisibility(r6)
            r3.setVisibility(r7)
            r2.setVisibility(r6)
            r5.setVisibility(r7)
            int r1 = biz.obake.team.touchprotector.g.a.j(r8)
            r2 = 2131624279(0x7f0e0157, float:1.8875733E38)
            java.lang.String r11 = biz.obake.team.touchprotector.c.w(r2)
            if (r1 < 0) goto L_0x00a8
            r2 = 100
            if (r1 > r2) goto L_0x00a8
            if (r11 == 0) goto L_0x00a4
            java.lang.StringBuilder r2 = new java.lang.StringBuilder
            r2.<init>()
            java.lang.String r4 = java.lang.Integer.toString(r1)
            r2.append(r4)
            java.lang.String r4 = "%"
            r2.append(r4)
            java.lang.String r13 = r2.toString()
            r14 = 0
            r15 = 4
            r16 = 0
            java.lang.String r12 = "{0}"
            java.lang.String r2 = d.k.m.d(r11, r12, r13, r14, r15, r16)
            goto L_0x00c6
        L_0x00a4:
            d.h.b.c.f()
            throw r10
        L_0x00a8:
            if (r11 == 0) goto L_0x00d2
            r1 = 2131624281(0x7f0e0159, float:1.8875737E38)
            java.lang.String r13 = biz.obake.team.touchprotector.c.w(r1)
            if (r13 == 0) goto L_0x00ce
            java.lang.String r1 = "Utils.resStr(R.string.pv_backlignt_no_control)!!"
            d.h.b.c.b(r13, r1)
            r14 = 0
            r15 = 4
            r16 = 0
            java.lang.String r12 = "{0}"
            java.lang.String r2 = d.k.m.d(r11, r12, r13, r14, r15, r16)
            int r1 = r5.getMax()
        L_0x00c6:
            r5.setProgress(r1)
            r3.setText(r2)
            goto L_0x017b
        L_0x00ce:
            d.h.b.c.f()
            throw r10
        L_0x00d2:
            d.h.b.c.f()
            throw r10
        L_0x00d6:
            java.lang.String r8 = "design"
            boolean r4 = r4.equals(r8)
            if (r4 == 0) goto L_0x0176
            android.view.View r4 = r0.f1601b
            r4.setVisibility(r7)
            r1.setVisibility(r7)
            r4 = 2131624282(0x7f0e015a, float:1.887574E38)
            java.lang.String r11 = biz.obake.team.touchprotector.c.w(r4)
            java.lang.String r4 = "LfdState.getInstance()"
            if (r11 == 0) goto L_0x010b
            biz.obake.team.touchprotector.lfd.f r8 = biz.obake.team.touchprotector.lfd.f.d()
            d.h.b.c.b(r8, r4)
            java.lang.String r13 = r8.f()
            java.lang.String r8 = "LfdState.getInstance().title"
            d.h.b.c.b(r13, r8)
            r14 = 0
            r15 = 4
            r16 = 0
            java.lang.String r12 = "{0}"
            java.lang.String r11 = d.k.m.d(r11, r12, r13, r14, r15, r16)
        L_0x010b:
            r1.setText(r11)
            biz.obake.team.touchprotector.lfd.f r1 = biz.obake.team.touchprotector.lfd.f.d()
            d.h.b.c.b(r1, r4)
            java.lang.String r1 = r1.e()
            java.lang.String r4 = "preset:0"
            boolean r1 = d.h.b.c.a(r4, r1)
            if (r1 == 0) goto L_0x012b
            r3.setVisibility(r6)
            r2.setVisibility(r6)
            r5.setVisibility(r6)
            goto L_0x017b
        L_0x012b:
            r3.setVisibility(r7)
            r2.setVisibility(r7)
            r5.setVisibility(r6)
            r1 = 2131624284(0x7f0e015c, float:1.8875743E38)
            java.lang.String r4 = biz.obake.team.touchprotector.c.w(r1)
            r3.setText(r4)
            java.lang.String r4 = "lock_frame_opacity"
            int r4 = biz.obake.team.touchprotector.g.a.j(r4)
            java.lang.String r11 = biz.obake.team.touchprotector.c.w(r1)
            if (r11 == 0) goto L_0x0172
            java.lang.String r13 = java.lang.Integer.toString(r4)
            java.lang.String r1 = "Integer.toString(opacity)"
            d.h.b.c.b(r13, r1)
            r14 = 0
            r15 = 4
            r16 = 0
            java.lang.String r12 = "{0}"
            java.lang.String r1 = d.k.m.d(r11, r12, r13, r14, r15, r16)
            r3.setText(r1)
            int r1 = r2.getMax()
            int r1 = r1 * r4
            float r1 = (float) r1
            r3 = 1120403456(0x42c80000, float:100.0)
            float r1 = r1 / r3
            int r1 = java.lang.Math.round(r1)
            r2.setProgress(r1)
            goto L_0x017b
        L_0x0172:
            d.h.b.c.f()
            throw r10
        L_0x0176:
            android.view.View r1 = r0.f1601b
            r1.setVisibility(r6)
        L_0x017b:
            android.view.View r1 = r0.f1601b
            android.view.ViewGroup$LayoutParams r1 = r1.getLayoutParams()
            if (r1 == 0) goto L_0x01b4
            android.widget.RelativeLayout$LayoutParams r1 = (android.widget.RelativeLayout.LayoutParams) r1
            r2 = 10
            r1.addRule(r2, r7)
            r3 = 15
            r1.addRule(r3, r7)
            r4 = 12
            r1.addRule(r4, r7)
            biz.obake.team.touchprotector.f.c$a r5 = r0.f1602c
            int[] r6 = biz.obake.team.touchprotector.f.d.f1610a
            int r5 = r5.ordinal()
            r5 = r6[r5]
            r6 = 1
            if (r5 == r6) goto L_0x01b0
            r2 = 2
            if (r5 == r2) goto L_0x01ac
            r2 = 3
            if (r5 == r2) goto L_0x01a8
            goto L_0x01b3
        L_0x01a8:
            r1.addRule(r4)
            goto L_0x01b3
        L_0x01ac:
            r1.addRule(r3)
            goto L_0x01b3
        L_0x01b0:
            r1.addRule(r2)
        L_0x01b3:
            return
        L_0x01b4:
            d.e r1 = new d.e
            java.lang.String r2 = "null cannot be cast to non-null type android.widget.RelativeLayout.LayoutParams"
            r1.<init>(r2)
            throw r1
        L_0x01bc:
            d.e r1 = new d.e
            r1.<init>(r4)
            throw r1
        L_0x01c2:
            d.e r1 = new d.e
            r1.<init>(r4)
            throw r1
        L_0x01c8:
            d.e r1 = new d.e
            r1.<init>(r2)
            throw r1
        L_0x01ce:
            d.e r1 = new d.e
            r1.<init>(r2)
            throw r1
        */
        throw new UnsupportedOperationException("Method not decompiled: biz.obake.team.touchprotector.f.c.c():void");
    }

    public void d() {
        l.a.b(this);
    }
}
